﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gota.Common.PlugIns;
using System.Runtime.Serialization;
using Library.Services.Authentication.Types.Security;

namespace Gota.Common.Deployment
{
    [Serializable]
    public class DeploymentConfiguration
    {
        private List<DeploymentDocument> documents;
        public string UserID { get; set; }
        public string SessionID { get; set; }
        public string ProjectName { get; set; }
        public int DeploymentConfigID { get; set; }

        public List<DeploymentDocument> Documents
        {
            get
            {
                if (documents == null)
                {
                    documents = new List<DeploymentDocument>();
                }

                return documents;
            }
            set
            {
                documents = value;
            }
        }

        public static DeploymentConfiguration CreateStandart(string documentText, string sessionId, int deploymentConfigId, string projectName)
        {
            DeploymentDocument document = new DeploymentDocument();
            document.DocumentType = DeploymentDocumentTypes.Document;
            document.ContentData = documentText;

            DeploymentConfiguration deploymentConfig = new DeploymentConfiguration();
            deploymentConfig.ProjectName = projectName;
            deploymentConfig.SessionID = sessionId;
            deploymentConfig.UserID = SecurityContext.CurrentUser.UserInfo.SystemUserEntity.UserName;
            deploymentConfig.DeploymentConfigID = deploymentConfigId;
            deploymentConfig.Documents.Add(document);

            return deploymentConfig;
        }

    }
}
